package com.andnnl.thread;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by chenss on 2020/12/25.
 */
public class ThreadPoolTest {
    public static void main(String[] args) throws InterruptedException {
        ExecutorService exe = Executors.newFixedThreadPool(2);
        CountDownLatch count=new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            int finalI = i;
            exe.execute(()->{
                System.out.println("start "+finalI);
                count.countDown();
                throw new RuntimeException("a");
//                System.out.println("end "+finalI);
            });
        }
        System.out.println("await...");
        count.await();
        System.out.println("await...end");
        exe.shutdown();
        System.out.println(exe.isShutdown());
    }
}
